<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3>${error}</h3>
	<form action="crudOrderCustomer.do?userid=${userId}" method="post">
		<table>	
			<tr>
				<td>
					ID
				</td>
				
				<td>
					<input type="text" readonly="readonly" name="txtId" value="${entityOrderCustom.id}"/>
				</td>
			</tr>
			
			<tr>
				<td>
					Ghi Chú
				</td>
				
				<td>
					<input type="text" name="txtNote" value="${entityOrderCustom.note}"/>
				</td>
			</tr>
			
			<tr>
				<td>
					Địa chỉ
				</td>
				
				<td>
					<input type="text" name="txtAddress" value="${entityOrderCustom.address}" required/>
					<input type="hidden" name="txtUserId" value="${userId}"/>
				</td>
			</tr>
			
			<tr>
				<td colspan="2">
					<input type="submit" name="btnCreate" value="Create"/>
					<input type="submit" name="btnUpdate" value="Update"/>
					<input type="submit" name="btnDelete" value="Delete"/>
				</td>
			</tr>
		</table>
	</form>
	
	<h2>Thông tin các đơn hàng mà bạn đã gởi.</h2>

	<table width="100%" border="1">
		<tr>
			<td>ID</td>
			<td>Order Date</td>
			<td>Note</td>
			<td>Customer's Name</td>
			<td>Address</td>
			<td>State</td>
			<td></td>
		</tr>
		
		<c:forEach var="s" items="${entityOrder}">
			<tr>
				<td>${s.id}</td>
				<td>${s.orderDate }</td>
				<td>${s.note}</td>
				<td>${s.customer.name}</td>
				<td>${s.address}</td>
				<td>
					<c:choose>
					<c:when test="${s.state == false}">
					   	<a href="crudOrderCustomer.do?orderid=${s.id}&userid=${userId}">Thay đổi</a>
					</c:when>
					<c:otherwise>
					   	Đã duyệt
					</c:otherwise>
					</c:choose>
				</td>				
				<td>
					<a href="crudOrderDetailCustomer.do?orderid=${s.id}">Chi tiết Order</a>
				</td>
			</tr>
		</c:forEach>
	</table>

</body>
</html>